package com.example.springbootsfzy.service.liujinping;

import com.example.springbootsfzy.domain.CoursePurchaseRecords;
import com.example.springbootsfzy.mapper.CoursePurchaseRecordsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursePurchaseRecordsService {
    @Autowired
    private CoursePurchaseRecordsMapper coursePurchaseRecordsMapper;
    public List<CoursePurchaseRecords> getAllRecords() {
        return coursePurchaseRecordsMapper.getAllRecords();
    }

    public CoursePurchaseRecords getRecordsById(Long id) {
        return coursePurchaseRecordsMapper.selectByPrimaryKey(id);
    }
    public int addRecords(CoursePurchaseRecords coursePurchaseRecords) {
        return coursePurchaseRecordsMapper.insert(coursePurchaseRecords);
    }

    public int updateRecords(CoursePurchaseRecords coursePurchaseRecords) {
        return coursePurchaseRecordsMapper.updateByPrimaryKey(coursePurchaseRecords);
    }

    public int updateRecordsActive(CoursePurchaseRecords coursePurchaseRecords) {
        return coursePurchaseRecordsMapper.updateByPrimaryKeySelective(coursePurchaseRecords);
    }

    public int deleteRecords(Long id) {
        return coursePurchaseRecordsMapper.deleteByPrimaryKey(id);
    }

    //通过课程id查询购买信息
    public List<CoursePurchaseRecords> getRecordsByCourseId(Integer id) {
        return coursePurchaseRecordsMapper.getRecordsByCourseId(id);
    }
}
